#ifndef GRID_H_
#define GRID_H_

#include "Graph.h"

/* Managed a Graph. allows for easy creation and rendering, and 
   also provides implementations for several advanced path Finding 
   methods 
*/
class Grid
{
public:
    Grid();
    ~Grid();
    void CreateNodes(int numX, int numY, float distX, float distY,const D3DXVECTOR3& startPos);
    void CreateEdges(bool diagionals = true);
    void SetNodeDrawSize(const D3DXVECTOR3& size);
    float EucludianHeristic(int startNode, int finalNode) const;
    float ManhattanHeuristic(int startNode, int finalNode) const;

    bool PathFindDepthFirst(int start, int finish, std::list<int>* path) const;
    bool PathFindBreadthFirst(int start, int finish, std::list<int>* path) const;
    bool DijkstraSeach(int start, int finish, std::list<int>* path) const;
    bool AStarSearch(int start, int finish, std::list<int>* path) const ;

    void DrawNodes(ID3DXEffect* effect) const;
    void DrawEdges(ID3DXEffect* effect) const;
    const Graph& GetGraph() const;
    Graph* GraphPtr() {return &m_graph;}

    int GetNearestNode(const D3DXVECTOR3& position, float sphereRad) const;
    void DrawEdge(int start, int finish, const D3DXVECTOR3& color) const;
    void DrawNode( int start, const  D3DXVECTOR3& color ) const;
private:
    int m_gridSizeX;
    int m_gridSizeY;
    float m_nodeDistanceX;
    float m_nodeDistanceY;
    Graph m_graph;
    D3DXVECTOR3 m_nodeDrawDirection;
    int* m_quater0;
    int* m_quater1;
    int* m_quater2;
    int* m_quater3;
};
#endif
